from django.db import models
from django.contrib.auth.models import User


# Create your models here.
class Goods(models.Model):
    # 商品表
    title = models.CharField('商品名', max_length=32)
    price = models.IntegerField('商品价格', default=100)
    img = models.ImageField(upload_to='goods')


class Order(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='orders')
    goods = models.ForeignKey(Goods, on_delete=models.CASCADE, related_name='order')
    count = models.IntegerField(default=1)

    class Meta:
        ordering = ['-id']


class Comment(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='comments')
    order = models.OneToOneField(Order, on_delete=models.CASCADE)
    content = models.TextField('评论内容')
